package com.xidian.zhiancloud.service.luling.systemconfiguration;

import com.xidian.zhiancloud.dao.RiskPointTypeStatusMapper;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.exception.CustomizeException;
import com.xidian.zhiancloud.model.RiskPointTypeStatus;
import com.xidian.zhiancloud.model.RiskPointTypeStatusExample;
import com.xidian.zhiancloud.model.WarSignCategoryStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class RiskPointTypeStatusService
{
    @Autowired
private RiskPointTypeStatusMapper  riskPointTypeStatusMapper;
    public void insert(RiskPointTypeStatus riskPointTypeStatus) {
        int count = riskPointTypeStatusMapper.insert(riskPointTypeStatus);
        if (count == 0) {
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
    }
        public void delete(RiskPointTypeStatus riskPointTypeStatus){
            RiskPointTypeStatusExample example = new RiskPointTypeStatusExample();
            RiskPointTypeStatusExample.Criteria criteria = example.createCriteria();
            criteria.andIdEqualTo(riskPointTypeStatus.getId());
            int count = riskPointTypeStatusMapper.deleteByExample(example);
            if (count == 0) {
                throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
            }

        }
        public void update (RiskPointTypeStatus riskPointTypeStatus){
                RiskPointTypeStatusExample example = new RiskPointTypeStatusExample();
                RiskPointTypeStatusExample.Criteria criteria = example.createCriteria();
                criteria.andIdEqualTo(riskPointTypeStatus.getId());
                RiskPointTypeStatus task = new RiskPointTypeStatus();
                task.setDescription(riskPointTypeStatus.getDescription());
                int count = riskPointTypeStatusMapper.updateByExampleSelective(task, example);
                if (count == 0) {
                    throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
            }
        }

        public void deleteByIds (Long[]ids){
        for (Long id : ids) {
                    int result = riskPointTypeStatusMapper.deleteByPrimaryKey(id);
                    if (result == 0) {
                        throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
                    }
        }
    }
}
//导入，导出
